home *** CD-ROM | disk | FTP | other *** search
- /*
- * WinLIB
- * Sound support
- */
-
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <string.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include "winlib.h"
- #include "internal.h"
- #include "config.h"
-
- char *_open_sound, *_close_sound, *_destroy_sound, *_min_sound, *_max_sound,
- *_start_sound, *_exit_sound, *_menudrop_sound, *_menusel_sound;
-
- void Win_SetSound(int type, char *f)
- {
- #ifdef SOUND_SUPPORT
- switch(type) {
- case SOUND_OPEN: _open_sound = (char *) malloc(strlen(f));
- strcpy(_open_sound, f);
- break;
- case SOUND_CLOSE: _close_sound = (char *) malloc(strlen(f));
- strcpy(_close_sound, f);
- break;
- case SOUND_DESTROY: _destroy_sound = (char *) malloc(strlen(f));
- strcpy(_destroy_sound, f);
- break;
- case SOUND_MINIMIZE: _min_sound = (char *) malloc(strlen(f));
- strcpy(_min_sound, f);
- break;
- case SOUND_MAXIMIZE: _max_sound = (char *) malloc(strlen(f));
- strcpy(_max_sound, f);
- break;
- case SOUND_START: _start_sound = (char *) malloc(strlen(f));
- strcpy(_start_sound, f);
- break;
- case SOUND_EXIT: _exit_sound = (char *) malloc(strlen(f));
- strcpy(_exit_sound, f);
- break;
- case SOUND_MENUDROP: _menudrop_sound = (char *) malloc(strlen(f));
- strcpy(_menudrop_sound, f);
- break;
- case SOUND_MENUSEL: _menusel_sound = (char *) malloc(strlen(f));
- strcpy(_menusel_sound, f);
- break;
- }
- #endif
- }
-
- void _play_sound(char *snd)
- {
- #ifdef SOUND_SUPPORT
- if (_sound_init) {
- char fn[160];
-
- bzero(fn, 160);
- sprintf(fn, "P%s\r\n", snd);
- write(_sound_socket, fn, strlen(fn));
- }
- #endif
- }
-
- void Win_PlaySound(int type)
- {
- #ifdef SOUND_SUPPORT
- switch(type) {
- case SOUND_OPEN: _play_sound(_open_sound); break;
- case SOUND_CLOSE: _play_sound(_close_sound); break;
- case SOUND_DESTROY: _play_sound(_destroy_sound); break;
- case SOUND_MINIMIZE: _play_sound(_min_sound); break;
- case SOUND_MAXIMIZE: _play_sound(_max_sound); break;
- case SOUND_START: _play_sound(_start_sound); break;
- case SOUND_EXIT: _play_sound(_exit_sound); break;
- case SOUND_MENUDROP: _play_sound(_menudrop_sound); break;
- case SOUND_MENUSEL: _play_sound(_menusel_sound); break;
- }
- #endif
- }
-